# -*- coding:utf-8 -*-
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
'''
核心思想就是判断下一个节点的值是不是和当前节点的值相等
如果相等的话就跳到下一个节点！
'''
class Solution:
    def deleteDuplication(self, pHead):
        # write code here
        pre = None
        cur = pHead
        while cur:
            # 如果重复
            if cur.next and cur.next.val == cur.val:
                # 再重复几次跳过几个节点
                while cur.next and cur.next.val == cur.val:
                    cur = cur.next
                # 再把外面这个重复的跳过去
                cur = cur.next
                # 还是null说明首节点重复 移动头节点
                if not pre:
                    pHead = cur
                else:
                    # 不是None 直接完成删除操作
                    pre.next = cur
            else:
                pre = cur
                cur = cur.next
        return pHead